<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
    <title>tslog demo</title>
</head>
<body>
<h1>tslog Demo</h1>

<script src="../../dist/browser/index.js"></script>
<script>
  class MyClass {
    _logger = new tslog.Logger({
      type: "pretty",
    });

    constructor() {
      this._logger.silly("I am a silly log.");
    }

    myMethod() {
      const jsonObj = {
        name: "John Doe",
        age: 30,
        cars: {
          car1: "Audi",
          car2: "BMW",
          car3: "Tesla",
        },
        obj: undefined,
      };
      jsonObj.obj = jsonObj;

      this._logger.debug("I am a debug log.");
      this._logger.info("I am an info log.");
      this._logger.warn("I am a warn log with a json object:", jsonObj);
      this._logger.error("I am an error log.");
      try {
        /* @ts-ignore */
        null.foo();
      } catch (err) {
        this._logger.fatal(err);
      }
    }
  }

  const myClass = new MyClass();
  myClass.myMethod();

  const log = new tslog.Logger({});
  log.silly("I am a silly log.");
  // log.trace("I am a trace log with a stack trace.");
  log.debug("I am a debug log.");
  log.info("I am an info log.");
  log.warn("I am a warn log with a json object:", { foo: "bar" });
  log.error("I am an error log.");
  log.fatal(new Error("I am a pretty Error with a stacktrace."));

  /*
   * Circular example
   * */
  function Foo() {
    /* @ts-ignore */
    this.abc = "Hello";
    /* @ts-ignore */
    this.circular = this;
  }
  /* @ts-ignore */
  const foo = new Foo();
  const logMessage = log.debug(foo);
  console.log("JSON.stringify circular log message", logMessage);

</script>
<script src="example.js"></script>
</body>
</html>
